﻿
using System;
using MedicWeb.forms;
using MedicWeb.MedicService;

namespace MedicWeb
{
    public partial class Main : SessionPage
    {
        protected void Page_Load(object sender, EventArgs e) {
            Form.Action = ResolveUrl("~/Login.aspx");
            if (GetSession() != null) {
                Response.Redirect("~/forms/empty.aspx");
            }
        }

        protected void Button1_Click(object sender, EventArgs e) {
            var ms = new MainService();
            var login = tfLogin.Text;
            var password = pfPassword.Text;
            Session session = ms.Login(login, password);
            if (session != null) {
                Session[SessionKey] = session;
                Session["info"] = "Вход выполнен";
                Response.Redirect("~/forms/empty.aspx");
                return;
            }
            Session["error"] = "Вход не выполнен";
        }
    }
            
}